<?php

class Default_Model_Data extends Kernel_Model
{

	public function getLastDrawing()
	{
		$query = '
			SELECT
					`drawing`
			FROM
					`data`
			ORDER BY
					`drawing` DESC
			LIMIT
					1
		';

		return (int)database::fetchOne($query);
	}

	public function setData($values)
	{
		$fields = array('drawing', 'date', '1', '2', '3', '4', '5', '6', '7', '8',
			'9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20');
		
		return database::insertValues('data', $fields, $values, true);
	}

	public function getData()
	{
		$query = '
			SELECT
					`1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`,
					`13`, `14`, `15`, `16`, `17`, `18`, `19`, `20`
			FROM
					`data`
			ORDER BY
					`drawing` ASC
		';

		return database::fetchAll($query);
	}

	/**
	 * Return self instance
	 *
	 * @return Default_Model_Data
	 */
	static public function getInstance()
	{
		return new self;
	}

}